import request from "@/utils/request";

/**
 * 获取处置列表接口
 * @param {*} query
 * @returns
 */
export function handleEventList(query) {
  return request({
    url: "/hd/handle/list",
    method: "get",
    params: query,
  });
}

/**
 * 立即处置接口
 * @param {*} query
 * @returns
 */
export function handleExecute(data) {
  return request({
    url: "/hd/handle",
    method: "put",
    data: data,
  });
}

/**
 * 获取处置详情信息接口
 * 通过处置主标ID获取主表带字表一对多的处置详情信息
 * 在处置过程中需要调整响应级别或者更换预案，按操作是重开一个处置（handle）所以存在一对多的数据
 * 因为这个接口需要调用西宁的预案数据，为了避免查询频繁和时间过长，所以这个接口只给详情页用
 *
 * @param {*} handleId
 * @returns
 */
export function handleEventInfo(handleId) {
  return request({
    url: "/hd/handle/" + handleId,
    method: "get",
  });
}

/**
 * 查询处置列表
 * 简易查询，不涉及预案信息
 * 主要用于救援处置选择器，用来回看或者评估
 *
 * @param {*} handleInfoId
 * @returns
 */
export function getHandleListByHandleInfoId(handleInfoId) {
  return request({
    url: "/hd/handle/queryHandles/" + handleInfoId,
    method: "get",
  });
}

/**
 * 获取处置基础信息
 * @param {*} handleId
 * @returns
 */
export function getHandleBaseInfo(handleId) {
  return request({
    url: "/hd/handle/base/" + handleId,
    method: "get",
  });
}

/**
 * 获取处置任务列表接口
 * @param {*} query
 * @returns
 */
export function handleTaskList(query) {
  return request({
    url: "/hd/task/list",
    method: "get",
    params: query,
  });
}

/**
 * 获取任务详情接口
 * @param {*} taskId
 * @returns
 */
export function getTaskInfo(taskId) {
  return request({
    url: "/hd/task/" + taskId,
    method: "get",
  });
}

/**
 * 提交任务接口
 * @param {*} data
 * @returns
 */
export function handleSubmitTask(data) {
  return request({
    url: "/hd/submitTask",
    method: "post",
    data: data,
  });
}

/**
 * 指派任务接口
 * @param {*} data
 * @returns
 */
export function handleTaskSet(data) {
  return request({
    url: "/hd/task",
    method: data.taskId == 0 ? "post" : "put",
    data: data,
  });
}

/**
 * 获取指派任务列表接口
 * @param {*} query
 * @returns
 */
export function getHandleTasksList(query) {
  return request({
    url: "/hd/task/selectHdTaskList",
    method: "get",
    params: query,
  });
}

/**
 * 结束处置
 * @param {*} data
 * @returns
 */
export function setHandleEnd(data) {
  return request({
    url: "/hd/handle/stopHandle",
    method: "put",
    data: data,
  });
}

/**
 * 提交保存处置报告
 * @param {*} data
 * @returns
 */
export function saveHandleReport(data) {
  return request({
    url: "/hd/report/insertReportAndScores",
    method: "post",
    data: data,
  });
}

/**
 * 提交处置报告
 * @param {*} data
 * @returns
 */
export function submitHandleReport(data) {
  return request({
    url: "/hd/report",
    method: "put",
    data: data,
  });
}

/**
 * 获取处置报告列表
 * @returns
 */
export function getHandleReportList(query) {
  return request({
    url: "/hd/report/list",
    method: "get",
    params: query,
  });
}

/**
 * 调整响应级别
 * @param {*} data
 * @returns
 */
export function setHandleResponseLevel(data) {
  return request({
    url: "/hd/handle/setResponse",
    method: "put",
    data: data,
  });
}

/**
 * 获取任务反馈附件列表
 * @param {*} query
 * @returns
 */
export function getTaskReportAttachs(taskId) {
  return request({
    url: "/hd/task/selectAttachsByTaskId/" + taskId,
    method: "get",
  });
}

/**
 * 单独查询指定流程下任务列表
 * @param {*} taskId
 * @returns
 */
export function getHandleLevelTasks(query) {
  return request({
    url: "/hd/handle/planHandle/tasks",
    method: "get",
    params: query,
  });
}

/**
 * 设置任务执行人接口
 * @param {*} data
 * @returns
 */
export function updateReceiveUser(data) {
  return request({
    url: "/hd/saveTask/updateReceiveUser",
    method: "put",
    data: data,
  });
}

/**
 * 开启流程
 * @param {*} data
 * @returns
 */
export function openHandle(data) {
  return request({
    url: "/hd/handle/openHandle",
    method: "put",
    data: data,
  });
}

/**
 * 获取处置下的处置记录
 * @param {*} query
 * @returns
 */
export function getHandlesByInfoId(handleInfoId) {
  return request({
    url: "/hd/report/selectReportList/" + handleInfoId,
    method: "get",
  });
}

/**
 * 删除或者取消任务
 * @param {*} data
 * @returns
 */
export function stopTask(taskId) {
  return request({
    url: "/hd/saveTask/cancelOrDel/" + taskId,
    method: "put",
  });
}

/**
 * 获取匹配的预案
 * @param {*} infoId
 * @returns
 */
export function getRelationPlans(infoId) {
  return request({
    url: "/duty/info/selectPlaList/" + infoId,
    method: "get",
  });
}

/**
 * @deprecated
 * 创建救援计划
 * @param {*} data
 * @returns
 */
export function savePlan(data) {
  return request({
    url: "/hd/handle",
    method: "post",
    data: data,
  });
}

/**
 * 救援计划总指挥设置
 * @param {*} data
 * @returns
 */
export function planLeaderSet(data) {
  return request({
    url: "/hd/HandleInfo/setHandleLeader",
    method: "put",
    data: data,
  });
}

/**
 * 获取一二级救援任务列表
 * @param {*} param
 */
export function getHandleTaskList(userId, params) {
  return request({
    url: "/hd/saveTask/selectAllHandleTasks/" + userId,
    method: "get",
    params: params,
  });
}

/**
 * 查询二级子任务列表
 * @param {*} params
 * @returns
 */
export function getHandleSonTaskList(taskId) {
  return request({
    url: "/hd/saveTask/selectTasksByParentId/" + taskId,
    method: "get",
  });
}

/**
 * 查询处置节点进度
 */
export function getHandleProgress(handleId) {
  return request({
    url: "/hd/handle/getHandleProgress/" + handleId,
    method: "get",
  });
}
